//
// File: psdoptions.cpp
//
// MATLAB Coder version            : 5.4
// C/C++ source code generated on  : 23-Apr-2025 16:26:18
//

// Include Files
#include "psdoptions.h"
#include "ismember.h"
#include "rt_nonfinite.h"
#include <cstring>
#include <string.h>

// Function Definitions
//
// Arguments    : const double arg_data[]
//                const int arg_size[2]
//                boolean_T *err
//                double visitedOpts[16]
//                double *b_index
// Return Type  : void
//
namespace coder {
void checkUniqueOpts(const double arg_data[], const int arg_size[2],
                     boolean_T *err, double visitedOpts[16], double *b_index)
{
  int tf_size[2];
  int k;
  boolean_T exitg1;
  boolean_T tf_data;
  boolean_T y;
  *b_index = 1.0;
  std::memset(&visitedOpts[0], 0, 16U * sizeof(double));
  isMember(arg_size, (boolean_T *)&tf_data, tf_size);
  y = (tf_size[1] != 0);
  if (y) {
    k = 0;
    exitg1 = false;
    while ((!exitg1) && (k <= tf_size[1] - 1)) {
      if (!tf_data) {
        y = false;
        exitg1 = true;
      } else {
        k = 1;
      }
    }
  }
  if (y) {
    *err = true;
  } else {
    boolean_T guard1{false};
    boolean_T guard2{false};
    tf_size[1] = arg_size[1];
    k = arg_size[1];
    for (int i{0}; i < k; i++) {
      tf_data = (arg_data[0] == 1.0);
    }
    y = (arg_size[1] != 0);
    if (y) {
      k = 0;
      exitg1 = false;
      while ((!exitg1) && (k <= tf_size[1] - 1)) {
        if (!tf_data) {
          y = false;
          exitg1 = true;
        } else {
          k = 1;
        }
      }
    }
    guard1 = false;
    guard2 = false;
    if (y) {
      guard2 = true;
    } else {
      int loop_ub_tmp;
      loop_ub_tmp = arg_size[1] - 1;
      for (int i{0}; i <= loop_ub_tmp; i++) {
        tf_data = (tf_data || (arg_data[0] == 2.0));
      }
      y = (arg_size[1] != 0);
      if (y) {
        k = 0;
        exitg1 = false;
        while ((!exitg1) && (k <= tf_size[1] - 1)) {
          if (!tf_data) {
            y = false;
            exitg1 = true;
          } else {
            k = 1;
          }
        }
      }
      if (y) {
        guard2 = true;
      } else {
        tf_size[1] = arg_size[1];
        k = arg_size[1];
        for (int i{0}; i < k; i++) {
          tf_data = (arg_data[0] == 3.0);
        }
        y = (arg_size[1] != 0);
        if (y) {
          k = 0;
          exitg1 = false;
          while ((!exitg1) && (k <= tf_size[1] - 1)) {
            if (!tf_data) {
              y = false;
              exitg1 = true;
            } else {
              k = 1;
            }
          }
        }
        if (y) {
          guard2 = true;
        } else {
          tf_size[1] = arg_size[1];
          k = arg_size[1];
          for (int i{0}; i < k; i++) {
            tf_data = (arg_data[0] == 4.0);
          }
          y = (arg_size[1] != 0);
          if (y) {
            k = 0;
            exitg1 = false;
            while ((!exitg1) && (k <= tf_size[1] - 1)) {
              if (!tf_data) {
                y = false;
                exitg1 = true;
              } else {
                k = 1;
              }
            }
          }
          if (y) {
            guard2 = true;
          } else {
            tf_size[1] = arg_size[1];
            k = arg_size[1];
            for (int i{0}; i < k; i++) {
              tf_data = (arg_data[0] == 5.0);
            }
            y = (arg_size[1] != 0);
            if (y) {
              k = 0;
              exitg1 = false;
              while ((!exitg1) && (k <= tf_size[1] - 1)) {
                if (!tf_data) {
                  y = false;
                  exitg1 = true;
                } else {
                  k = 1;
                }
              }
            }
            if (y) {
              guard1 = true;
            } else {
              for (int i{0}; i <= loop_ub_tmp; i++) {
                tf_data = (tf_data || (arg_data[0] == 6.0));
              }
              y = (arg_size[1] != 0);
              if (y) {
                k = 0;
                exitg1 = false;
                while ((!exitg1) && (k <= tf_size[1] - 1)) {
                  if (!tf_data) {
                    y = false;
                    exitg1 = true;
                  } else {
                    k = 1;
                  }
                }
              }
              if (y) {
                guard1 = true;
              } else {
                tf_size[1] = arg_size[1];
                k = arg_size[1];
                for (int i{0}; i < k; i++) {
                  tf_data = (arg_data[0] == 7.0);
                }
                y = (arg_size[1] != 0);
                if (y) {
                  k = 0;
                  exitg1 = false;
                  while ((!exitg1) && (k <= tf_size[1] - 1)) {
                    if (!tf_data) {
                      y = false;
                      exitg1 = true;
                    } else {
                      k = 1;
                    }
                  }
                }
                if (y) {
                  guard1 = true;
                } else {
                  visitedOpts[0] = arg_data[0];
                  *b_index = 2.0;
                }
              }
            }
          }
        }
      }
    }
    if (guard2) {
      visitedOpts[0] = 1.0;
      visitedOpts[1] = 2.0;
      visitedOpts[2] = 3.0;
      visitedOpts[3] = 4.0;
      *b_index = 4.0;
    }
    if (guard1) {
      visitedOpts[0] = 5.0;
      visitedOpts[1] = 6.0;
      visitedOpts[2] = 7.0;
      *b_index = 3.0;
    }
    *err = false;
  }
}

} // namespace coder

//
// File trailer for psdoptions.cpp
//
// [EOF]
//
